agent-sin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +21 -0
  3. package/README.md +81 -0
  4. package/assets/logo.png +0 -0
  5. package/builtin-skills/_shared/_models_lib.py +227 -0
  6. package/builtin-skills/_shared/_profile_lib.py +98 -0
  7. package/builtin-skills/_shared/_schedules_lib.py +313 -0
  8. package/builtin-skills/_shared/_skill_settings_lib.py +153 -0
  9. package/builtin-skills/_shared/i18n.py +26 -0
  10. package/builtin-skills/memo-delete/main.py +155 -0
  11. package/builtin-skills/memo-delete/skill.yaml +57 -0
  12. package/builtin-skills/memo-index/main.py +178 -0
  13. package/builtin-skills/memo-index/skill.yaml +53 -0
  14. package/builtin-skills/memo-save/README.md +5 -0
  15. package/builtin-skills/memo-save/main.py +74 -0
  16. package/builtin-skills/memo-save/skill.yaml +52 -0
  17. package/builtin-skills/memo-search/README.md +10 -0
  18. package/builtin-skills/memo-search/main.py +97 -0
  19. package/builtin-skills/memo-search/skill.yaml +51 -0
  20. package/builtin-skills/memo-vector-search/main.py +121 -0
  21. package/builtin-skills/memo-vector-search/skill.yaml +53 -0
  22. package/builtin-skills/model-add/main.py +180 -0
  23. package/builtin-skills/model-add/skill.yaml +112 -0
  24. package/builtin-skills/model-list/main.py +93 -0
  25. package/builtin-skills/model-list/skill.yaml +48 -0
  26. package/builtin-skills/model-set/main.py +123 -0
  27. package/builtin-skills/model-set/skill.yaml +69 -0
  28. package/builtin-skills/profile-delete/_profile_lib.py +98 -0
  29. package/builtin-skills/profile-delete/main.py +98 -0
  30. package/builtin-skills/profile-delete/skill.yaml +64 -0
  31. package/builtin-skills/profile-edit/_profile_lib.py +98 -0
  32. package/builtin-skills/profile-edit/main.py +97 -0
  33. package/builtin-skills/profile-edit/skill.yaml +72 -0
  34. package/builtin-skills/profile-save/main.py +52 -0
  35. package/builtin-skills/profile-save/skill.yaml +69 -0
  36. package/builtin-skills/schedule-add/_schedules_lib.py +303 -0
  37. package/builtin-skills/schedule-add/main.py +137 -0
  38. package/builtin-skills/schedule-add/skill.yaml +94 -0
  39. package/builtin-skills/schedule-list/_schedules_lib.py +303 -0
  40. package/builtin-skills/schedule-list/main.py +86 -0
  41. package/builtin-skills/schedule-list/skill.yaml +45 -0
  42. package/builtin-skills/schedule-remove/_schedules_lib.py +303 -0
  43. package/builtin-skills/schedule-remove/main.py +69 -0
  44. package/builtin-skills/schedule-remove/skill.yaml +49 -0
  45. package/builtin-skills/schedule-toggle/_schedules_lib.py +303 -0
  46. package/builtin-skills/schedule-toggle/main.py +78 -0
  47. package/builtin-skills/schedule-toggle/skill.yaml +61 -0
  48. package/builtin-skills/skills-disable/main.py +63 -0
  49. package/builtin-skills/skills-disable/skill.yaml +52 -0
  50. package/builtin-skills/skills-enable/main.py +62 -0
  51. package/builtin-skills/skills-enable/skill.yaml +51 -0
  52. package/builtin-skills/todo-add/main.py +68 -0
  53. package/builtin-skills/todo-add/skill.yaml +53 -0
  54. package/builtin-skills/todo-delete/main.py +65 -0
  55. package/builtin-skills/todo-delete/skill.yaml +47 -0
  56. package/builtin-skills/todo-done/main.py +75 -0
  57. package/builtin-skills/todo-done/skill.yaml +47 -0
  58. package/builtin-skills/todo-list/main.py +91 -0
  59. package/builtin-skills/todo-list/skill.yaml +48 -0
  60. package/builtin-skills/todo-tick/main.py +125 -0
  61. package/builtin-skills/todo-tick/skill.yaml +48 -0
  62. package/dist/builder/build-action-classifier.d.ts +18 -0
  63. package/dist/builder/build-action-classifier.js +142 -0
  64. package/dist/builder/build-commands.d.ts +19 -0
  65. package/dist/builder/build-commands.js +133 -0
  66. package/dist/builder/build-flow.d.ts +72 -0
  67. package/dist/builder/build-flow.js +416 -0
  68. package/dist/builder/builder-session.d.ts +117 -0
  69. package/dist/builder/builder-session.js +1129 -0
  70. package/dist/builder/conversation-router.d.ts +22 -0
  71. package/dist/builder/conversation-router.js +69 -0
  72. package/dist/builder/intent-runtime-store.d.ts +7 -0
  73. package/dist/builder/intent-runtime-store.js +60 -0
  74. package/dist/builder/progress-format.d.ts +7 -0
  75. package/dist/builder/progress-format.js +46 -0
  76. package/dist/cli/index.d.ts +2 -0
  77. package/dist/cli/index.js +2835 -0
  78. package/dist/cli/spinner.d.ts +30 -0
  79. package/dist/cli/spinner.js +164 -0
  80. package/dist/core/ai-provider.d.ts +75 -0
  81. package/dist/core/ai-provider.js +678 -0
  82. package/dist/core/builtin-skills.d.ts +27 -0
  83. package/dist/core/builtin-skills.js +120 -0
  84. package/dist/core/chat-engine.d.ts +70 -0
  85. package/dist/core/chat-engine.js +812 -0
  86. package/dist/core/config.d.ts +127 -0
  87. package/dist/core/config.js +1379 -0
  88. package/dist/core/daily-memory-promotion.d.ts +21 -0
  89. package/dist/core/daily-memory-promotion.js +422 -0
  90. package/dist/core/i18n.d.ts +23 -0
  91. package/dist/core/i18n.js +167 -0
  92. package/dist/core/info-lines.d.ts +5 -0
  93. package/dist/core/info-lines.js +39 -0
  94. package/dist/core/input-schema.d.ts +2 -0
  95. package/dist/core/input-schema.js +156 -0
  96. package/dist/core/intent-router.d.ts +27 -0
  97. package/dist/core/intent-router.js +160 -0
  98. package/dist/core/logger.d.ts +60 -0
  99. package/dist/core/logger.js +240 -0
  100. package/dist/core/memory.d.ts +10 -0
  101. package/dist/core/memory.js +72 -0
  102. package/dist/core/message-utils.d.ts +13 -0
  103. package/dist/core/message-utils.js +104 -0
  104. package/dist/core/notifier.d.ts +17 -0
  105. package/dist/core/notifier.js +424 -0
  106. package/dist/core/output-writer.d.ts +13 -0
  107. package/dist/core/output-writer.js +100 -0
  108. package/dist/core/plan-decision.d.ts +16 -0
  109. package/dist/core/plan-decision.js +88 -0
  110. package/dist/core/profile-memory.d.ts +17 -0
  111. package/dist/core/profile-memory.js +142 -0
  112. package/dist/core/runtime.d.ts +50 -0
  113. package/dist/core/runtime.js +187 -0
  114. package/dist/core/scheduler.d.ts +28 -0
  115. package/dist/core/scheduler.js +155 -0
  116. package/dist/core/secrets.d.ts +31 -0
  117. package/dist/core/secrets.js +214 -0
  118. package/dist/core/service.d.ts +35 -0
  119. package/dist/core/service.js +479 -0
  120. package/dist/core/skill-planner.d.ts +24 -0
  121. package/dist/core/skill-planner.js +100 -0
  122. package/dist/core/skill-registry.d.ts +98 -0
  123. package/dist/core/skill-registry.js +319 -0
  124. package/dist/core/skill-scaffold.d.ts +33 -0
  125. package/dist/core/skill-scaffold.js +256 -0
  126. package/dist/core/skill-settings.d.ts +11 -0
  127. package/dist/core/skill-settings.js +63 -0
  128. package/dist/core/transfer.d.ts +31 -0
  129. package/dist/core/transfer.js +270 -0
  130. package/dist/core/update-notifier.d.ts +2 -0
  131. package/dist/core/update-notifier.js +140 -0
  132. package/dist/discord/bot.d.ts +96 -0
  133. package/dist/discord/bot.js +2424 -0
  134. package/dist/runtimes/codex-app-server.d.ts +53 -0
  135. package/dist/runtimes/codex-app-server.js +305 -0
  136. package/dist/runtimes/python-runner.d.ts +7 -0
  137. package/dist/runtimes/python-runner.js +302 -0
  138. package/dist/runtimes/typescript-runner.d.ts +5 -0
  139. package/dist/runtimes/typescript-runner.js +172 -0
  140. package/dist/skills-sdk/types.d.ts +38 -0
  141. package/dist/skills-sdk/types.js +1 -0
  142. package/dist/telegram/bot.d.ts +94 -0
  143. package/dist/telegram/bot.js +1219 -0
  144. package/install.ps1 +132 -0
  145. package/install.sh +130 -0
  146. package/package.json +60 -0
  147. package/templates/skill-python/main.py +74 -0
  148. package/templates/skill-python/skill.yaml +48 -0
  149. package/templates/skill-typescript/main.ts +87 -0
  150. package/templates/skill-typescript/skill.yaml +42 -0
package/install.ps1 ADDED
@@ -0,0 +1,132 @@
1
+ # Agent-Sin installer for Windows.
2
+ #
3
+ # Usage:
4
+ # irm https://<install-host>/install.ps1 | iex
5
+ # $args = @('--yes'); irm https://<install-host>/install.ps1 | iex
6
+ #
7
+ # Or after downloading:
8
+ # powershell -ExecutionPolicy Bypass -File .\install.ps1 -Yes
9
+ #
10
+ # Equivalent of install.sh: installs the agent-sin command globally,
11
+ # runs `agent-sin setup`, and registers the Task Scheduler logon task.
12
+
13
+ [CmdletBinding()]
14
+ param(
15
+ [switch]$Yes,
16
+ [string]$Model,
17
+ [string]$Builder,
18
+ [switch]$Help
19
+ )
20
+
21
+ $ErrorActionPreference = 'Stop'
22
+
23
+ $AppName = 'agent-sin'
24
+ $NpmPackage = if ($env:AGENT_SIN_NPM_PACKAGE) { $env:AGENT_SIN_NPM_PACKAGE } else { 'agent-sin' }
25
+ $MinNodeMajor = 22
26
+
27
+ function Use-Japanese {
28
+ if ($env:AGENT_SIN_LOCALE -match '^ja') { return $true }
29
+ if ($env:AGENT_SIN_LOCALE -match '^en') { return $false }
30
+ $locale = if ($env:LC_ALL) { $env:LC_ALL } elseif ($env:LANG) { $env:LANG } else { [System.Globalization.CultureInfo]::CurrentUICulture.Name }
31
+ return $locale -match '^ja'
32
+ }
33
+
34
+ function Msg([string]$En, [string]$Ja) {
35
+ if (Use-Japanese) { $Ja } else { $En }
36
+ }
37
+
38
+ function Show-Usage {
39
+ if (Use-Japanese) {
40
+ @'
41
+ Agent-Sin installer (Windows)
42
+
43
+ 使い方:
44
+ irm https://<install-host>/install.ps1 | iex
45
+ powershell -ExecutionPolicy Bypass -File .\install.ps1 [-Yes] [-Model <id>] [-Builder <id>]
46
+
47
+ オプション:
48
+ -Yes setup をプロンプトなしで実行
49
+ -Model <id> agent-sin setup に既定モデルを渡す
50
+ -Builder <id> agent-sin setup に builder モデルを渡す
51
+ -Help このヘルプを表示
52
+
53
+ 環境変数:
54
+ AGENT_SIN_NPM_PACKAGE インストールする npm package (既定: agent-sin)
55
+ '@
56
+ } else {
57
+ @'
58
+ Agent-Sin installer (Windows)
59
+
60
+ Usage:
61
+ irm https://<install-host>/install.ps1 | iex
62
+ powershell -ExecutionPolicy Bypass -File .\install.ps1 [-Yes] [-Model <id>] [-Builder <id>]
63
+
64
+ Options:
65
+ -Yes Run setup without prompts
66
+ -Model <id> Pass default model to agent-sin setup
67
+ -Builder <id> Pass builder model to agent-sin setup
68
+ -Help Show this help
69
+
70
+ Environment:
71
+ AGENT_SIN_NPM_PACKAGE npm package to install (default: agent-sin)
72
+ '@
73
+ }
74
+ }
75
+
76
+ if ($Help) {
77
+ Show-Usage
78
+ exit 0
79
+ }
80
+
81
+ function Require-Command([string]$Name) {
82
+ if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
83
+ Write-Error (Msg "agent-sin install: missing required command: $Name" "agent-sin install: 必要なコマンドが見つかりません: $Name")
84
+ exit 1
85
+ }
86
+ }
87
+
88
+ Require-Command 'node'
89
+ Require-Command 'npm'
90
+
91
+ $nodeVersion = (& node -p "process.versions.node").Trim()
92
+ $nodeMajor = [int]($nodeVersion.Split('.')[0])
93
+ if ($nodeMajor -lt $MinNodeMajor) {
94
+ Write-Error (Msg "agent-sin install: Node.js $MinNodeMajor or newer is required. Current: v$nodeVersion" "agent-sin install: Node.js $MinNodeMajor 以上が必要です。現在: v$nodeVersion")
95
+ exit 1
96
+ }
97
+
98
+ Write-Host (Msg "agent-sin install: installing $NpmPackage globally..." "agent-sin install: $NpmPackage をグローバルインストールしています...")
99
+ & npm install -g $NpmPackage
100
+ if ($LASTEXITCODE -ne 0) {
101
+ Write-Error (Msg "agent-sin install: npm install failed." "agent-sin install: npm install に失敗しました。")
102
+ exit 1
103
+ }
104
+
105
+ if (-not (Get-Command $AppName -ErrorAction SilentlyContinue)) {
106
+ Write-Warning (Msg "agent-sin install: installed, but '$AppName' is not on PATH." "agent-sin install: インストール済みですが '$AppName' が PATH にありません。")
107
+ Write-Host (Msg "Check your npm global bin path with: npm bin -g" "npm bin -g で npm の global bin path を確認してください。")
108
+ Write-Host (Msg "You may need to open a new PowerShell so PATH refreshes." "PATH を反映するには新しい PowerShell を開く必要がある場合があります。")
109
+ exit 1
110
+ }
111
+
112
+ $setupArgs = New-Object System.Collections.Generic.List[string]
113
+ if ($Yes) { $setupArgs.Add('--yes') }
114
+ if ($Model) { $setupArgs.Add('--model'); $setupArgs.Add($Model) }
115
+ if ($Builder) { $setupArgs.Add('--builder'); $setupArgs.Add($Builder) }
116
+
117
+ Write-Host (Msg "agent-sin install: running setup..." "agent-sin install: setup を実行しています...")
118
+ & $AppName setup @setupArgs
119
+ if ($LASTEXITCODE -ne 0) {
120
+ Write-Error (Msg "agent-sin install: setup failed." "agent-sin install: setup に失敗しました。")
121
+ exit 1
122
+ }
123
+
124
+ Write-Host (Msg "agent-sin install: installing service..." "agent-sin install: service をインストールしています...")
125
+ & $AppName service install
126
+ if ($LASTEXITCODE -ne 0) {
127
+ Write-Warning (Msg "agent-sin install: service install reported a non-zero exit. Run 'agent-sin service status' for details." "agent-sin install: service install が非ゼロで終了しました。詳細は 'agent-sin service status' を実行してください。")
128
+ }
129
+
130
+ Write-Host ''
131
+ Write-Host (Msg 'agent-sin install: ready' 'agent-sin install: 準備完了')
132
+ Write-Host (Msg 'Next: agent-sin service status' '次: agent-sin service status')
package/install.sh ADDED
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ APP_NAME="agent-sin"
5
+ NPM_PACKAGE="${AGENT_SIN_NPM_PACKAGE:-agent-sin}"
6
+ MIN_NODE_MAJOR=22
7
+
8
+ setup_args=()
9
+
10
+ locale_is_ja() {
11
+ case "${AGENT_SIN_LOCALE:-}" in
12
+ ja|ja_*) return 0 ;;
13
+ en|en_*) return 1 ;;
14
+ esac
15
+ case "${LC_ALL:-${LANG:-}}" in
16
+ ja*|JA*) return 0 ;;
17
+ *) return 1 ;;
18
+ esac
19
+ }
20
+
21
+ msg() {
22
+ if locale_is_ja; then
23
+ printf '%s\n' "$2"
24
+ else
25
+ printf '%s\n' "$1"
26
+ fi
27
+ }
28
+
29
+ usage() {
30
+ if locale_is_ja; then
31
+ cat <<'EOF'
32
+ Agent-Sin installer
33
+
34
+ 使い方:
35
+ curl -fsSL https://<install-host>/install.sh | bash
36
+ curl -fsSL https://<install-host>/install.sh | bash -s -- --yes
37
+
38
+ agent-sin コマンドをインストールし、setup を実行してログインサービスを登録します。
39
+
40
+ オプション:
41
+ --yes, --defaults, --no-input setup をプロンプトなしで実行
42
+ --model <id> agent-sin setup に既定モデルを渡す
43
+ --builder <id> agent-sin setup に builder モデルを渡す
44
+ --help このヘルプを表示
45
+
46
+ 環境変数:
47
+ AGENT_SIN_NPM_PACKAGE インストールする npm package (既定: agent-sin)
48
+ EOF
49
+ else
50
+ cat <<'EOF'
51
+ Agent-Sin installer
52
+
53
+ Usage:
54
+ curl -fsSL https://<install-host>/install.sh | bash
55
+ curl -fsSL https://<install-host>/install.sh | bash -s -- --yes
56
+
57
+ Installs the agent-sin command, runs setup, and registers the login service.
58
+
59
+ Options:
60
+ --yes, --defaults, --no-input Run setup without prompts
61
+ --model <id> Pass default model to agent-sin setup
62
+ --builder <id> Pass builder model to agent-sin setup
63
+ --help Show this help
64
+
65
+ Environment:
66
+ AGENT_SIN_NPM_PACKAGE npm package to install (default: agent-sin)
67
+ EOF
68
+ fi
69
+ }
70
+
71
+ while [[ $# -gt 0 ]]; do
72
+ case "$1" in
73
+ --help|-h)
74
+ usage
75
+ exit 0
76
+ ;;
77
+ --yes|--defaults|--no-input)
78
+ setup_args+=("$1")
79
+ shift
80
+ ;;
81
+ --model|--builder)
82
+ if [[ $# -lt 2 ]]; then
83
+ msg "agent-sin install: $1 requires a value" "agent-sin install: $1 には値が必要です" >&2
84
+ exit 1
85
+ fi
86
+ setup_args+=("$1" "$2")
87
+ shift 2
88
+ ;;
89
+ *)
90
+ msg "agent-sin install: unknown option: $1" "agent-sin install: 不明なオプションです: $1" >&2
91
+ msg "Run with --help for usage." "--help で使い方を確認してください。" >&2
92
+ exit 1
93
+ ;;
94
+ esac
95
+ done
96
+
97
+ need_cmd() {
98
+ if ! command -v "$1" >/dev/null 2>&1; then
99
+ msg "agent-sin install: missing required command: $1" "agent-sin install: 必要なコマンドが見つかりません: $1" >&2
100
+ return 1
101
+ fi
102
+ }
103
+
104
+ need_cmd node
105
+ need_cmd npm
106
+
107
+ node_major="$(node -p "Number(process.versions.node.split('.')[0])")"
108
+ if [[ "$node_major" -lt "$MIN_NODE_MAJOR" ]]; then
109
+ msg "agent-sin install: Node.js $MIN_NODE_MAJOR or newer is required. Current: $(node -v)" "agent-sin install: Node.js $MIN_NODE_MAJOR 以上が必要です。現在: $(node -v)" >&2
110
+ exit 1
111
+ fi
112
+
113
+ msg "agent-sin install: installing $NPM_PACKAGE globally..." "agent-sin install: $NPM_PACKAGE をグローバルインストールしています..."
114
+ npm install -g "$NPM_PACKAGE"
115
+
116
+ if ! command -v "$APP_NAME" >/dev/null 2>&1; then
117
+ msg "agent-sin install: installed, but '$APP_NAME' is not on PATH." "agent-sin install: インストール済みですが '$APP_NAME' が PATH にありません。" >&2
118
+ msg "Check your npm global bin path with: npm bin -g" "npm bin -g で npm の global bin path を確認してください。" >&2
119
+ exit 1
120
+ fi
121
+
122
+ msg "agent-sin install: running setup..." "agent-sin install: setup を実行しています..."
123
+ "$APP_NAME" setup "${setup_args[@]}"
124
+
125
+ msg "agent-sin install: installing service..." "agent-sin install: service をインストールしています..."
126
+ "$APP_NAME" service install
127
+
128
+ echo ""
129
+ msg "agent-sin install: ready" "agent-sin install: 準備完了"
130
+ msg "Next: agent-sin service status" "次: agent-sin service status"
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "agent-sin",
3
+ "version": "0.1.0",
4
+ "description": "Program Skill-first personal AI agent OS CLI.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Agent-Sin contributors",
8
+ "homepage": "https://agent.shingoirie.com",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/iritec/agent-sin.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/iritec/agent-sin/issues"
15
+ },
16
+ "main": "./dist/cli/index.js",
17
+ "types": "./dist/skills-sdk/types.d.ts",
18
+ "bin": {
19
+ "agent-sin": "./dist/cli/index.js"
20
+ },
21
+ "files": [
22
+ "dist/",
23
+ "assets/",
24
+ "install.sh",
25
+ "install.ps1",
26
+ "builtin-skills/",
27
+ "templates/",
28
+ "!builtin-skills/**/__pycache__",
29
+ "!builtin-skills/**/*.pyc",
30
+ "README.md",
31
+ "CHANGELOG.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "build": "node scripts/build-dist.mjs",
36
+ "setup": "npm ci --include=dev && npm run build && node scripts/local-cli.mjs setup",
37
+ "setup:global": "npm ci --include=dev && npm run build && npm link && agent-sin setup && agent-sin service install",
38
+ "start": "npm run build && node scripts/local-cli.mjs chat",
39
+ "demo": "npm run build && node scripts/local-cli.mjs setup && node scripts/local-cli.mjs run memo-save --text test-memo",
40
+ "test": "npm run build && node --test tests/*.test.mjs",
41
+ "smoke:providers": "npm run build && node scripts/smoke-providers.mjs",
42
+ "prepack": "npm run build",
43
+ "pack:check": "npm pack --dry-run",
44
+ "release:check": "npm test && npm run pack:check"
45
+ },
46
+ "dependencies": {
47
+ "nodemailer": "^8.0.7",
48
+ "typescript": "^5.9.3",
49
+ "ws": "^8.20.0",
50
+ "yaml": "^2.7.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.10.0",
54
+ "@types/nodemailer": "^8.0.0",
55
+ "@types/ws": "^8.18.1"
56
+ },
57
+ "engines": {
58
+ "node": ">=22"
59
+ }
60
+ }
@@ -0,0 +1,74 @@
1
+ """Agent-Sin Skill (Python) - template
2
+
3
+ The entry point is run(ctx, input). Runtime provides:
4
+
5
+ ctx.log.info(msg) / warn / error : writes to logs/runs/<run-id>.json and events.jsonl
6
+ ctx.memory.get(key) / set(key, v) : persists under skill.yaml memory.namespace
7
+ ctx.ai.run(step_id, payload) : calls an ai_steps entry declared in skill.yaml
8
+ ctx.notify(args) : notifies Discord/Telegram/macOS/Mail/Slack/stderr (auto recommended)
9
+ ctx.now() : returns the current time as an ISO8601 string
10
+
11
+ input format:
12
+ {
13
+ "args": arguments validated by skill.yaml input.schema,
14
+ "trigger": {"type": "manual", "id": ..., "time": "ISO8601"},
15
+ "sources": {"workspace": ..., "notes_dir": ..., ...},
16
+ "memory": current ctx.memory snapshot,
17
+ }
18
+
19
+ Return a SkillResult. outputs.<id> maps to outputs[id] in skill.yaml.
20
+ Runtime saves outputs, so the skill should not write files directly.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+
26
+ def _locale(input):
27
+ locale = str((input.get("sources", {}) or {}).get("locale") or "").lower()
28
+ return "ja" if locale.startswith("ja") else "en"
29
+
30
+
31
+ def _t(input, en, ja):
32
+ return ja if _locale(input) == "ja" else en
33
+
34
+
35
+ async def run(ctx, input):
36
+ args = input.get("args", {})
37
+ text = str(args.get("text", "")).strip()
38
+
39
+ # Return status: skipped for empty input. Runtime logs it without saving outputs.
40
+ if not text:
41
+ return {
42
+ "status": "skipped",
43
+ "title": _t(input, "No input", "入力なし"),
44
+ "summary": _t(input, "Skipped because text is empty.", "text が空のためスキップしました"),
45
+ "outputs": {},
46
+ "data": {},
47
+ "suggestions": [],
48
+ }
49
+
50
+ # ctx.log also writes to events.jsonl, which is useful for debugging.
51
+ ctx.log.info(f"example-skill: processing {len(text)} chars")
52
+
53
+ # ctx.memory is persisted per namespace. Use it for small state such as run counts.
54
+ # Reads can use the input["memory"] snapshot; writes use await ctx.memory.set.
55
+ runs = int(input.get("memory", {}).get("runs", 0)) + 1
56
+ await ctx.memory.set("runs", runs)
57
+
58
+ timestamp = input.get("trigger", {}).get("time") or ctx.now()
59
+ content = f"- {timestamp} {text}\n"
60
+
61
+ # outputs.note maps to outputs[id=note] in skill.yaml. Runtime saves it by path/filename.
62
+ return {
63
+ "status": "ok",
64
+ "title": _t(input, "Processed", "処理しました"),
65
+ "summary": _t(input, f"Saved text (total {runs} run(s))", f"text を保存しました (累計 {runs} 回)"),
66
+ "outputs": {
67
+ "note": {
68
+ "content": content,
69
+ "frontmatter": {"tags": ["example"]},
70
+ }
71
+ },
72
+ "data": {"length": len(text), "runs": runs},
73
+ "suggestions": [],
74
+ }
@@ -0,0 +1,48 @@
1
+ # Agent-Sin Skill manifest (Python)
2
+ # Required fields: id, runtime
3
+ # entry/handler default to main.py / run, so they can usually be omitted.
4
+ # Common optional: name, description, input, outputs, memory, ai_steps, required_env
5
+ # See https://agent.shingoirie.com/skill-authoring for the full reference.
6
+
7
+ id: example-skill # Unique skill ID (kebab-case)
8
+ name: Example Skill # Human-readable name
9
+ description: Example skill generated from the template
10
+ runtime: python # python | typescript
11
+
12
+ # Hints for chat invocation (optional)
13
+ invocation:
14
+ command: example.run
15
+ phrases:
16
+ - run the example
17
+ - sample
18
+
19
+ # input.schema validates args passed to run(). Explicit required fields are safer.
20
+ input:
21
+ schema:
22
+ type: object
23
+ properties:
24
+ text:
25
+ type: string
26
+ description: Text to process
27
+ required:
28
+ - text
29
+
30
+ # Declare outputs when you want Runtime to save Markdown/JSON files.
31
+ # This sample appends a Markdown note. {{yyyy}}/{{MM}}/{{date}} are available.
32
+ outputs:
33
+ - id: note
34
+ type: markdown
35
+ path: notes/examples
36
+ filename: "{{date}}-example.md"
37
+ append: true
38
+
39
+ # Persistent memory namespace used by ctx.memory.get/set.
40
+ memory:
41
+ namespace: example
42
+ read: true
43
+ write: true
44
+
45
+ # Optional: set "raw" only when you want to return the summary directly to users.
46
+ # By default, the LLM receives the result and formats a natural-language reply.
47
+ # See https://agent.shingoirie.com/skill-authoring for details.
48
+ # output_mode: raw
@@ -0,0 +1,87 @@
1
+ // Agent-Sin Skill (TypeScript) - template
2
+ //
3
+ // Export run(ctx, input) directly; do not default-export it.
4
+ // Runtime provides:
5
+ //
6
+ // ctx.log.info(msg) / warn / error writes to logs/runs/<run-id>.json and events.jsonl
7
+ // ctx.memory.get(key) / set(key, v) persists under skill.yaml memory.namespace
8
+ // ctx.ai.run(step_id, payload) calls an ai_steps entry declared in skill.yaml
9
+ // ctx.notify(args) notifies Discord/Telegram/macOS/Mail/Slack/stderr (auto recommended)
10
+ // ctx.now() current time as an ISO8601 string
11
+ //
12
+ // See src/skills-sdk/types.ts for SkillInput / SkillResult.
13
+ // Runtime handles saving, notifications, and cron; skills should not touch fs directly.
14
+
15
+ interface SkillCtx {
16
+ log: { info: (m: string) => void; warn: (m: string) => void; error: (m: string) => void };
17
+ // Prefer input.memory for reads; writes use await ctx.memory.set.
18
+ memory: {
19
+ get: (key: string) => Promise<unknown>;
20
+ set: (key: string, value: unknown) => Promise<boolean>;
21
+ };
22
+ ai: { run: (stepId: string, payload: unknown) => Promise<unknown> };
23
+ notify: (args: {
24
+ title: string;
25
+ body: string;
26
+ subtitle?: string;
27
+ sound?: boolean;
28
+ channel?: "auto" | "macos" | "discord" | "telegram" | "slack" | "mail" | "stderr";
29
+ to?: string;
30
+ discordThreadId?: string;
31
+ telegramThreadId?: string;
32
+ }) => Promise<{ ok: boolean; channel: string; detail?: string }>;
33
+ now: () => string;
34
+ }
35
+
36
+ interface SkillInput {
37
+ args: Record<string, unknown>;
38
+ trigger: { type: string; id: string; time: string };
39
+ sources: Record<string, unknown> & { locale?: string };
40
+ memory: Record<string, unknown>;
41
+ }
42
+
43
+ function locale(input: SkillInput): "en" | "ja" {
44
+ return String(input.sources?.locale || "").toLowerCase().startsWith("ja") ? "ja" : "en";
45
+ }
46
+
47
+ function tr(input: SkillInput, en: string, ja: string): string {
48
+ return locale(input) === "ja" ? ja : en;
49
+ }
50
+
51
+ export async function run(ctx: SkillCtx, input: SkillInput) {
52
+ const text = String(input.args?.text ?? "").trim();
53
+
54
+ if (!text) {
55
+ return {
56
+ status: "skipped" as const,
57
+ title: tr(input, "No input", "入力なし"),
58
+ summary: tr(input, "Skipped because text is empty.", "text が空のためスキップしました"),
59
+ outputs: {},
60
+ data: {},
61
+ suggestions: [],
62
+ };
63
+ }
64
+
65
+ ctx.log.info(`example-ts-skill: processing ${text.length} chars`);
66
+
67
+ const previous = Number(input.memory?.runs ?? 0);
68
+ const runs = previous + 1;
69
+ await ctx.memory.set("runs", runs);
70
+
71
+ const timestamp = input.trigger?.time || ctx.now();
72
+ const content = `- ${timestamp} ${text}\n`;
73
+
74
+ return {
75
+ status: "ok" as const,
76
+ title: tr(input, "Processed", "処理しました"),
77
+ summary: tr(input, `Saved text (total ${runs} run(s))`, `text を保存しました (累計 ${runs} 回)`),
78
+ outputs: {
79
+ note: {
80
+ content,
81
+ frontmatter: { tags: ["example-ts"] },
82
+ },
83
+ },
84
+ data: { length: text.length, runs },
85
+ suggestions: [],
86
+ };
87
+ }
@@ -0,0 +1,42 @@
1
+ # Agent-Sin Skill manifest (TypeScript)
2
+ # Required fields: id, runtime
3
+ # entry/handler default to main.ts / run, so they can usually be omitted.
4
+ # Common optional: name, description, input, outputs, memory, ai_steps, required_env
5
+ # See https://agent.shingoirie.com/skill-authoring for the full reference.
6
+
7
+ id: example-ts-skill # Unique skill ID (kebab-case)
8
+ name: Example TypeScript Skill
9
+ description: Example TypeScript skill generated from the template
10
+ runtime: typescript # python | typescript
11
+
12
+ invocation:
13
+ command: example.ts.run
14
+ phrases:
15
+ - run the TypeScript example
16
+
17
+ input:
18
+ schema:
19
+ type: object
20
+ properties:
21
+ text:
22
+ type: string
23
+ description: Text to process
24
+ required:
25
+ - text
26
+
27
+ outputs:
28
+ - id: note
29
+ type: markdown
30
+ path: notes/examples
31
+ filename: "{{date}}-example-ts.md"
32
+ append: true
33
+
34
+ memory:
35
+ namespace: example-ts
36
+ read: true
37
+ write: true
38
+
39
+ # Optional: set "raw" only when you want to return the summary directly to users.
40
+ # By default, the LLM receives the result and formats a natural-language reply.
41
+ # See https://agent.shingoirie.com/skill-authoring for details.
42
+ # output_mode: raw