Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mac-app/Tip/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
"Settings.configuration.programmable.recheck" = "Recheck";
"Settings.configuration.programmable.edit" = "Open the script in an editor";
"Settings.configuration.programmable.log" = "Show log";
"Settings.configuration.programmable.ai.title" = "Write it with an AI agent";
"Settings.configuration.programmable.ai.explanation" = "Copy the instruction below and paste it into an AI agent such as Claude Code. Replace the part in square brackets with the Tips you want.";
"Settings.configuration.programmable.ai.copy" = "Copy the instruction";
"Settings.configuration.programmable.ai.copied" = "Copied";
"Settings.configuration.detail.description" = "Description";
"Settings.configuration.detail.match" = "Match Rule";
"Settings.configuration.detail.command.explanation" = "Use **{input}** to represent the selected text.";
Expand Down
4 changes: 4 additions & 0 deletions mac-app/Tip/Localization/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
"Settings.configuration.programmable.recheck" = "再チェック";
"Settings.configuration.programmable.edit" = "スクリプトをエディタで開く";
"Settings.configuration.programmable.log" = "ログを表示";
"Settings.configuration.programmable.ai.title" = "AIエージェントで作成する";
"Settings.configuration.programmable.ai.explanation" = "下の指示をコピーして、Claude CodeなどのAIエージェントに貼り付けてください。角括弧の部分を、欲しいTipの説明に置き換えてください。";
"Settings.configuration.programmable.ai.copy" = "指示をコピー";
"Settings.configuration.programmable.ai.copied" = "コピーしました";
"Settings.configuration.detail.description" = "説明";
"Settings.configuration.detail.match" = "マッチルール";
"Settings.configuration.detail.command.explanation" = "Tipの実行方法の設定、**{input}** はハイライトされたテキストを表します...";
Expand Down
4 changes: 4 additions & 0 deletions mac-app/Tip/Localization/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
"Settings.configuration.programmable.recheck" = "다시 확인";
"Settings.configuration.programmable.edit" = "편집기에서 스크립트를 엽니다";
"Settings.configuration.programmable.log" = "로그 표시";
"Settings.configuration.programmable.ai.title" = "AI 에이전트로 작성하기";
"Settings.configuration.programmable.ai.explanation" = "아래 지시문을 복사하여 Claude Code 같은 AI 에이전트에 붙여넣으십시오. 대괄호 안의 내용을 원하는 Tip에 대한 설명으로 바꾸십시오.";
"Settings.configuration.programmable.ai.copy" = "지시문 복사";
"Settings.configuration.programmable.ai.copied" = "복사됨";
"Settings.configuration.detail.description" = "설명";
"Settings.configuration.detail.match" = "일치 규칙";
"Settings.configuration.detail.command.explanation" = "Tip이 실행되는 방식을 구성합니다. **{input}** 는 강조 표시된 텍스트를 나타냅니다...";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,42 @@ class ProgrammableTipsSettingsItemPresenter: ObservableObject {
case normal
}

/// An instruction to paste into an AI agent so that it writes or changes the provider script.
/// It's always in English, since it's addressed to the agent.
static var aiInstruction: String {
let path = ExternalTipper.Constants.providerPath.path
return """
Create or update my provider script for Programmable Tooltip (https://github.com/tanin47/tip), a macOS app \
that shows a tooltip of actions for the text I select.

The provider script:
- It lives at: \(path)
- If it already exists, read it first and add to it. Keep what's there unless I ask otherwise.
- It must be executable (chmod 755). It can be written in any language.
- Programmable Tooltip runs it as: provider.script <selected-text> --bundle-identifier <bundle-id>
- It must print one JSON array of items on stdout and exit with status 0. Print [] when there is nothing \
to offer.
- It must finish within 15 seconds.

The items:
- {"type": "text", "label": "Shown label", "value": "Copied to the clipboard when picked"}
- {"type": "url", "label": "Shown label", "value": "https://a-url-opened-when-picked"}
- {"type": "execute", "label": "Shown label", "args": ["--some-flag", "some-value"]}
When picked, the script is run again with only these args, and the items that run prints replace the \
tooltip's content.

Read the full guide before you write the script: \
https://github.com/tanin47/tip/blob/main/PROVIDER_SCRIPT.md

When you're done, run the script from a shell with the same arguments Programmable Tooltip uses, check \
that it prints a valid JSON array, and tell me what you couldn't test.

What I want:
[Describe the tips you want here. For example: "When I select a ticket ID like ABC-123, offer to open it \
in the browser."]
"""
}

init() {
checkScriptingFileState()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct ProgrammableTipsSettingsItemView: View {
@State
private var shouldShowErrorAlert: Bool = false

@State
private var hasCopiedAiInstruction: Bool = false

init() {
self.presenter = ProgrammableTipsSettingsItemPresenter()
}
Expand Down Expand Up @@ -70,6 +73,50 @@ struct ProgrammableTipsSettingsItemView: View {

Divider()

VStack(alignment: .leading, spacing: 8) {
Text(R.string.localizable.settingsConfigurationProgrammableAiTitle())
.font(.title)
.bold()

Text(R.string.localizable.settingsConfigurationProgrammableAiExplanation())
.multilineTextAlignment(.leading)
.lineSpacing(5)
.fixedSize(horizontal: false, vertical: true)

ScrollView {
Text(ProgrammableTipsSettingsItemPresenter.aiInstruction)
.font(.system(size: 11, design: .monospaced))
.textSelection(.enabled)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(8)
}
.frame(height: 130)
.border(.gray)

Button(action: {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(
ProgrammableTipsSettingsItemPresenter.aiInstruction,
forType: .string
)
hasCopiedAiInstruction = true
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
hasCopiedAiInstruction = false
}
}) {
HStack(spacing: 4) {
Image(systemName: hasCopiedAiInstruction ? "checkmark" : "doc.on.doc")
Text(
hasCopiedAiInstruction
? R.string.localizable.settingsConfigurationProgrammableAiCopied()
: R.string.localizable.settingsConfigurationProgrammableAiCopy()
)
}
}
}

Divider()

Text(
LocalizedStringKey(
R.string.localizable.settingsConfigurationDocs()
Expand Down